<?php
namespace app\index\controller;

class Cart extends CheckMember
{
    /**
     * 购物车
     * @return \think\response\View
     */
    public function index()
    {
        $param['member_id'] = session('member_id');
        $data = $this->local_invoke_api('get_cart_list', $param);
        $this->assign('data', $data['data']);
        return view();
    }

    /**
     * 加入购物车
     * @return \think\response\Json
     */
    public function add_cart() {
        $param = input('param.');
        $param['member_id'] = session('member_id');
        $data = $this->local_invoke_api('add_cart', $param);
        return json($data);
    }

    /**
     * 修改购物车商品数量
     * @return \think\response\Json
     */
    public function edit_num(){
        $param = input('param.');
        $param['member_id'] = session('member_id');
        $data = $this->local_invoke_api('edit_cart_product_num', $param);
        return json($data);
    }

    /**
     * 删除购物车
     * @return \think\response\Json
     */
    public function del_cart() {
        $param = input('param.');
        $param['member_id'] = session('member_id');
        $data = $this->local_invoke_api('del_cart', $param);
        return json($data);
    }
}
